import { getInfo as memberInfo } from '../../../../api/shareCenter'
const util = require('../../../../utils/util.js')

const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    memberInfo: { matchPoint: '0' },
  },

  loadPromoter() {
    memberInfo().then(res => {
      this.data.memberInfo = res.data
      this.setData({
        memberInfo: this.data.memberInfo
      })
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    this.setData({
      avatar: app.globalData.userInfo.avatar
    })
    this.data.canvasH = (wx.getSystemInfoSync().windowWidth / 750).toFixed(2)
    this.data.canvasHeight = 500 * this.data.canvasH
    this.setData({
      canvasHeight: this.data.canvasHeight
    })

  },

  onShow: function () {
    this.loadPromoter()
  },
  toDistribution() {
    wx.navigateTo({
      url: '/pages/wallet/jumpPage/integral/details',
    })
  },
  scanGiveClick() {
    wx.scanCode({
      success(res) {
        let s = decodeURIComponent(res.result);
        let w = s.indexOf('/q/');
        let x = s.substring(w + 3);
        if (w != -1) {
          wx.navigateTo({
            url: '/pages/wallet/jumpPage/integral/scanGive?xuid=' + x,
          })
        } else {
          wx.showToast({
            title: '无效二维码',
            icon: 'none',
            duration: 2000
          })
        }
      },
      fail(error) {
        wx.showToast({
          title: '无效二维码',
          icon: 'none',
          duration: 2000
        })
      }
    })
  }
})
